package com.iRomantic.common.util;

import java.util.UUID;

public class FileUtil {
	
	/**
	 * 随机生成文件名
	 * @param fileName
	 * @return
	 */
	public static String randomFileName(String fileName){
		String uuid = UUID.randomUUID().toString();
		if(fileName!=null){
			String[] suffix = fileName.split("\\.");
			if(suffix.length>0){
				fileName = uuid + "."+suffix[suffix.length-1];
			}
		}else{
			fileName = uuid;
		}
		return fileName;
	}
	
	/**
	 * 获取文件后缀名
	 * @param fileName
	 * @return
	 */
	public static String getSuffix(String fileName){
		String suffix = "";
		String[] array = fileName.split("\\.");
		if(array.length>0){
			suffix = array[array.length-1];
		}
		return suffix;
	}
}
